@using Microsoft.AspNetCore.Html;
@using Microsoft.CodeAnalysis;
@{
	ITypeSymbol modelSymbol = Model.Get<ITypeSymbol>("Symbol");
	IList<IDocument> methods = Model.List<IDocument>("ExtensionMethods")
		?.Where(x => x.Bool("IsResult"))
		.OrderBy(x => x["DisplayName"])
		.ToList();
	if(methods.Count > 0)
	{
		<text>
			<h1 id="ExtensionMethods">Extension Methods</h1>
			<div class="box">
				<div class="box-body no-padding table-responsive">
					<table class="table table-striped table-hover three-cols">
						<thead>
							<tr>
								<th>Name</th>
								<th>Value</th>
								<th>Summary</th>
							</tr>
						</thead>
						@foreach(IDocument method in methods)
						{
							ISymbol reducedSymbol = method.Get<IMethodSymbol>("Symbol")?.ReduceExtensionMethod(modelSymbol);
							string reducedName = reducedSymbol?.ToDisplayString(new SymbolDisplayFormat(
								typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes,
								genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters,
								parameterOptions: SymbolDisplayParameterOptions.IncludeType, 
								memberOptions: SymbolDisplayMemberOptions.IncludeParameters,
								miscellaneousOptions: SymbolDisplayMiscellaneousOptions.UseSpecialTypes));
							IDocument returnType = method.Get<IDocument>("ReturnType");
							<tr>
								<td>@Context.GetTypeLink(method, reducedName, false)</td>
								<td>@(returnType == null ? new HtmlString(string.Empty) : Context.GetTypeLink(returnType))</td>
								<td>
									<div>@Html.Raw(method["Summary"])</div>
									@{
										IDocument containingType = method.Document(CodeAnalysisKeys.ContainingType);
										<div><small><em>From @Context.GetTypeLink(containingType)</em></small></div>
									}
								</td>
							</tr>
						}
					</table>
				</div>
			</div>
		</text>
	}
}